<%@ page language="java" import="java.util.*,cn.bupt.adt.constant.Constants" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page  isELIgnored="false"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String ip = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+"/";
%>
<%
	//分页
	//currentPage就是当前页，allPages表示的就是一共有多少页。这些在后面都会用到  
	int currentPage = 0, allPages = 0;
	if (request.getAttribute("currentPage") != null) {
		currentPage = Integer.parseInt(request.getAttribute(
				"currentPage").toString());
	}
	if (request.getAttribute("allPages") != null) {
		allPages = Integer.parseInt(request.getAttribute("allPages")
				.toString());
	}
	//本页面url，翻页用
	String url = "institutionManagement/index";
	request.setAttribute("url", url);
	request.setAttribute("imageRootPath",ip+Constants.IMAGE_PATH);
%>
<!DOCTYPE html>
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title></title>
    

	<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
	<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/bootstrap.min.css" />

    <link href="<%=request.getContextPath()%>/assets/css/font-awesome.css" rel="stylesheet" />
    <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />
    <link rel="stylesheet" href="css/Orderfont.css"><link>
	<script src="assets/js/jquery-1.10.2.js"></script>
	<script src="assets/js/bootstrap.js"></script>
	<script type="text/javascript" src="js/public/buttonModal.js"></script>
	<script type="text/javascript" src="js/public/submitForm.js"></script>
	<link rel="stylesheet" href="layerui/css/layui.css"><link>
	  </head>
  
  <body>
  		  <div class="page-header">
		  		<h1><small>机构列表<i class="icon-double-angle-right"></i></small></h1>
			</div>
  	<div class="container">
  	
	<div class="table-responsive">
		<form action="institutionManagement/index/1" class="form-inline">
			<div class="form-group">
				<select name="searchMethod" class="form-control" >
					<option value="true" <c:if test="${searchMethod == true}">selected="selected"</c:if> >姓名搜索</option>
					<option value="false" <c:if test="${searchMethod == false}">selected="selected"</c:if>>电话搜索</option>
				</select>		
			</div>
			<div class="form-group">
				<input type="text" class="form-control" name="content" value="${content }">
			</div>
			<div class="form-group">
				<input type="submit" class="btn btn-primary" value="搜索">
			</div>	         
		</form>	
		<table class="table table-striped table-hover">
			<thead>
				<tr>
					<th>机构名称</th>
					<th>联系电话</th>
					<th>座机</th>
					<th>机构法人</th>
					<th>已发布订单数</th>
					<th>已完成订单数</th>
					<th>已完成订单金额</th>
					<th>已发布订单的手术类型</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
			<c:forEach items="${institutions}" var="item" varStatus="idx">
				<tr>
					<td>${item.name}</td>
					<td>${item.phone}</td>
					<td>${item.landline}</td>
					<td>${item.corporation}</td>
					<td>${item.publishOrderNum}</td>
					<td>${item.finishedOrderNum}</td>
					<td>${item.finishOrderMoney}</td>
					<td>${item.labels}</td>
					<td>
						<div>
							<a title="查看"  href="institutionManagement/insDetail/${item.institutionId }">
								<i class="layui-icon"  >&#xe642;</i>
							</a>
							<a title="删除机构" href="institutionManagement/deleteIns/${item.institutionId }" onclick="return confirm('该删除操作仅仅用于删除您刚刚因手误而增加的机构，对于正常的机构账号此操作会带来麻烦，您还要删除吗？'); ">
								<i class="layui-icon">&#xe640;</i>
							</a>							
						</div>					
					</td>
				</tr>
				  <div id="dev${idx.index }" class="modal fade">
      		<div class="modal-dialog " >
      			<div class="modal-content">
      				<div class="modal-header">
      					 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> 
      				</div>
      				<div class="modal-body">
      				<c:forEach var="img" items="${item.devs}" >
      				<div>
      					<img alt="机构设备照片" src="${imageRootPath}${img}" style="height: 100%;width: 100%">
      					</div>
      				</c:forEach>
      				</div>
      			</div>
      		</div>
      	</div>

	  <div id="cert${idx.index }" class="modal fade">
      		<div class="modal-dialog" >
      			<div class="modal-content">
      				<div class="modal-header">
      					 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> 
      				</div>
      				<div class="modal-body">
      				<c:forEach var="img" items="${item.certs}">
      					<div>
      					<img alt="执业证照片" src="${imageRootPath}${img}" style="height: 100%;width: 100%">
      					</div>
      				</c:forEach>
      				</div>
      			</div>
      		</div>
      	</div>      	
<%-- 	  <div id="appear${idx.index }" class="modal fade">
      		<div class="modal-dialog" >
      			<div class="modal-content">
      				<div class="modal-header">
      					 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> 
      				</div>
      				<div class="modal-body">
      				<c:forEach var="img" items="${item.appears}">
      					<div>
      					<img alt="职称证照片" src="${imageRootPath}${img}" style="height: 100%;width: 100%">
      					</div>
      				</c:forEach>
      				</div>
      			</div>
      		</div>
      	</div>	 --%>
							<div id="editPhoneModal${idx.index}" class="modal fade">
					      		<div class="modal-dialog">
					      			<div class="modal-content">
					      				<div class="modal-header">
					      					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
					      					<h1 class="modal-title">请输入手机号码</h1>
					      				</div>
					      				<div class="modal-body">
					      					<form action="institutionManagement/editPhone" method="post" id="form${idx.index}">
					      						<input type="hidden" name="id" value="${item.id}"/>
					      						<input type="text" name="phone"  class="form-control" placeholder="请输入新的电话" id="modifyPhone${idx.index}">
					      					</form>
					      				</div>
					      				<div class="modal-footer">
					      					<button type="button" class="btn btn-primary" id="sub${idx.index}">确认</button>
					      					<button type="button" class="btn btn-primary" data-dismiss="modal">取消</button>
					      					
					      				</div>
					      			</div>
					      		</div>
				      		</div>       	
			
			</c:forEach>

			</tbody>
			<tfoot>
				<tr>
					<td colspan="10" style="text-align:left">
			     	<c:if test="${allPages>1}">
			     	<ul class="pagination">
			     		<li ><a href="${url}/1">首页</a></li>
			     		<li><a href="javascript:void(0)" id="previous" onclick="dividePage('${url}','previous')">&laquo;</a></li>
			     		<c:forEach var="item" begin="1" end="${allPages }" varStatus="idx">
						  	<c:choose>
						  		<c:when test="${idx.index == currentPage }">
						  			<li class="active"><a href="javascript:void(0)" id="active">${idx.index}</a></li>
						  		</c:when>
						  		<c:otherwise>
						  			<li><a href="${url}/${idx.index}">${idx.index}</a></li>
						  		</c:otherwise>
						  	</c:choose>
						  </c:forEach>
					      <li><a href="javascript:void(0)" id="next" onclick="dividePage('${url}','next','${allPages}')">&raquo;</a></li>
			     			<li ><a href="${url}/${allPages}">尾页</a></li>
					</ul>			     	
			     	</c:if>
			     	
					
					</td>
				</tr>
			</tfoot>			
		</table>
	</div>
	</div>
	<script type="text/javascript" src="js/public/dividePage.js"></script>
	

  </body>
</html>